ValueFolder='/sps/isc/rneveu/EtudeIRM/Nature/Results/';
ValueFolderTemp='/sps/isc/rneveu/EtudeIRM/Nature/ResultsJournal/';
ValueFolderTemp2='/sps/isc/rneveu/EtudeIRM/Nature/ResultsEditor/';
load([ValueFolderTemp 'ResultsThirdLevelDistributionOutliers.mat']);
VecDistribution=VecResults;
ValueFolder2='/sps/isc/rneveu/EtudeIRM/Nature/';
load([ValueFolder2 'DonneesNature.mat']);
load([ValueFolder2 'EtudeNature.mat']);
VecEditors1Temp(1,:)=[];
ValueCutoff=1.25;
VecResultsEditor1=[];
VecResultsEditor2=[];
VecResultsEditor3=[];
for n1=1:33
    n1
    VecResultsJournalEditor=[];
    VecResultsTemp=[];
    n5=0;
    n6=0;
    for n2=1:323
        ValueTemp=find(VecDistribution(:,1)==n2);
        if n2~=11&&size(ValueTemp,1)==1&&VecDistribution(ValueTemp(1,1),2)<=ValueCutoff
            ValueTemp=dir([ValueFolderTemp2 'FileAnalysisCharacteristicsEditor' num2str(n2) '.mat']);
            if size(ValueTemp,1)==1
                load([ValueFolderTemp2 'FileAnalysisCharacteristicsEditor' num2str(n2) '.mat']); 
            end
            if VecResultsEditor(1,39)==n1&&VecResultsEditor(1,1)<40 % We remove the editor who has more than 40 article spublished
                VecResultsJournalEditor=[VecResultsJournalEditor;VecResultsEditor(1,1:38)];
                if strcmp(VecEditors1Temp{n2,13},'N')==1
                    VecResultsTemp=[VecResultsTemp;1];
                    VecResultsEditor1=[VecResultsEditor1;VecResultsEditor(1,13) VecResultsEditor(1,23) VecResultsEditor(1,3)];
                else
                    if strcmp(VecEditors1Temp{n2,13},'Y')==1
                        VecResultsTemp=[VecResultsTemp;0];
                        VecResultsEditor2=[VecResultsEditor2;VecResultsEditor(1,13) VecResultsEditor(1,23) VecResultsEditor(1,3)];
                    else
                        VecResultsTemp=[VecResultsTemp;-1];
                    end
                end
            end
        end
    end
    if size(VecResultsJournalEditor,1)>0
        ValueTemp=find(VecResultsTemp==1);
        ValueTemp2=find(VecResultsTemp==0);
        ValueTemp3=find(VecResultsTemp==-1);
        if size(VecResultsJournalEditor,1)>1
%             VecResultsJournalEditorTemp=nanmean(VecResultsJournalEditor);
            VecResultsJournalEditorTemp=sqrt(nanvar(VecResultsJournalEditor));
%             VecResultsJournalEditorTemp=nanmedian(VecResultsJournalEditor);
            VecResultsJournalEditorTemp2=sum(1-isnan(VecResultsJournalEditor));
        else
%             VecResultsJournalEditorTemp=VecResultsJournalEditor;
            VecResultsJournalEditorTemp=zeros(1,size(VecResultsJournalEditor,2));
            VecResultssJournalEditorTemp2=1-isnan(VecResultsJournalEditor);
        end
        VecResultsJournalEditor=[VecResultsJournalEditorTemp size(ValueTemp,1)/size(VecResultsTemp,1)*100 size(ValueTemp2,1)/size(VecResultsTemp,1)*100 size(ValueTemp3,1)/size(VecResultsTemp,1)*100 size(VecResultsJournalEditor,1) VecResultsJournalEditorTemp2 size(VecResultsTemp,1) size(VecResultsTemp,1) size(VecResultsTemp,1)];
    else
        VecResultsJournalEditor=[NaN(1,41) zeros(1,42)];
    end
    save([ValueFolderTemp 'FileAnalysisCharacteristicsEditorsJournal' num2str(n1) 'SD.mat']);
end